import React from 'react';
import { Form, Input, Button, Checkbox, notification } from 'antd';
import { useNavigate } from 'react-router-dom';
import service from '../../../api';

function Addbanner(props: any) {
    const navigator = useNavigate();

    const onFinish = async(values: any) => {
        console.log('Success:', values);
        const res = await service.banner.Addbanner(values);
        console.log(res);
        switch (res.data.code) {
            case "200":
                notification.success({ message: '添加成功' });
                navigator('/index/banner');
                break;
                default:
                break;
        }
    };
    return (
        <div>
            <Form

                labelCol={{ span: 5 }}
                wrapperCol={{ span: 16 }}
                style={{ maxWidth: 600,margin:'20px'}}
                onFinish={onFinish}
            >
                <Form.Item
                    label="轮播图链接"
                    name="link"
                    rules={[{ required: true, message: '请输入轮播图链接' }]}
                >
                    <Input />
                </Form.Item>
                <Form.Item
                    label="轮播图提示"
                    name="alt"
                    rules={[{ required: true, message: '请输入轮播图提示' }]}
                >
                    <Input />
                </Form.Item>
                <Form.Item
                    label="图片"
                    name="img"
                    rules={[{ required: true, message: '请输入图片地址' }]}
                >
                    <Input />
                </Form.Item>


                <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
                    <Button type="primary" htmlType="submit">
                        新增图片
                    </Button>
                </Form.Item>
            </Form>
        </div>
    );
}

export default Addbanner;